package top.superflow.flow.config.parse.center

import top.superflow.exception.RequestUnsupportedException
import top.superflow.flow.config.parse.impl.ProcessConfigParser
import top.superflow.flow.config.process.ProcessConfig

class ProcessConfigParserCenter private () extends ParserCenter[ ProcessConfig, ProcessConfigParser] {

  def getParser(processConfig : ProcessConfig) : ProcessConfigParser = {
    if(processConfig == null){
      throw new RequestUnsupportedException("The resource config should not be null!")
    }
    val processType = processConfig.getProcessType

    val processConfigParser = this.getParser(processType)
    if(processConfigParser == null){
      throw new RequestUnsupportedException("There is no registered parser for the process type " + processType)
    }

    processConfigParser
  }


}


object ProcessConfigParserCenter {
  private final val instance = new ProcessConfigParserCenter

  def getInstance = instance

}
